package com.operation.net.controller;

import com.operation.net.common.ApiRestResponse;
import com.operation.net.common.ExceptionEnum;
import com.operation.net.dto.SnmpMessageDTO;
import com.operation.net.service.MibDataAcqService;
import com.operation.net.vo.MibVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/mib")
public class MibController {

    @Autowired
    private MibDataAcqService mibDataAcqService;

    /*Mib*/
    @PostMapping("/getMib")
    public ApiRestResponse  getMib(@RequestBody SnmpMessageDTO snmpInfo){
        List<MibVO> mibVOList= mibDataAcqService.showMib(snmpInfo);
        if (mibVOList.isEmpty()){
            return ApiRestResponse.error(ExceptionEnum.GET_ERROR);
        }
        return ApiRestResponse.success(mibVOList);
    }

    /*Mib-Set*/
    @PostMapping("/setMib")
    public ApiRestResponse  setMib(@RequestBody SnmpMessageDTO snmpInfo){
        List<MibVO> mibVOList= mibDataAcqService.setMib(snmpInfo);
        if (mibVOList.isEmpty()){
            return ApiRestResponse.error(ExceptionEnum.SET_ERROR);
        }
        return ApiRestResponse.success();
    }



}
